<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"> 
    <h:form>
        <input type="submit" value="Novo" class="button" jsf:action="${cityManagedBean.openNew}" jsf:id="novo"/>
        <br/>
        <br/>    
        <fieldset>
            <legend> Consulta de Cidades </legend>
            <div class="messagesContainer"><h:messages warnClass="warnMessages" class="messages"/></div>
            <f:view>
                <h:panelGroup rendered="${not empty cityManagedBean.list}">
                    <table class="tableConsulta">   
                        <thead>
                            <tr>
                                <td>
                                    Nome
                                </td>
                                <td>
                                    Estado/Província
                                </td>
                                <td>
                                    País
                                </td>
                                <td>
                                    Editar
                                </td>                        
                                <td>
                                    Excluir
                                </td>                        
                            </tr>
                        </thead>
                        <ui:repeat value="${cityManagedBean.list}" var="city">
                            <tr>
                                <td>
                                    ${city.name}
                                </td>
                                <td>
                                    ${city.state}
                                </td>
                                <td>
                                    ${city.country}
                                </td>
                                <td>
                                    <input type="submit" class="buttonEdit" value="" jsf:action="${cityManagedBean.openToUpdate}" jsf:id="editar">
                            <f:param value="${city.id}" name="id"/>
                            </input>
                            </td>
                            <td>
                            <input type="submit" class="buttonDelete" value="" jsf:action="${cityManagedBean.delete}" jsf:id="deletar">
                                <f:param value="${city.id}" name="id"/>
                            </input>
                            </td>
                            </tr>                       
                        </ui:repeat>
                    </table>
                </h:panelGroup>
                <h:panelGroup rendered="${empty cityManagedBean.list}">
                    <br/>Ainda não há cidades cadastradas.
                </h:panelGroup>

            </f:view>
        </fieldset>    
    </h:form>
</html>

